import React from 'react';
import ProCard from '@ant-design/pro-card';
import ProTable, { ProColumns } from '@ant-design/pro-table';
import styles from '../index.less';
import moment from 'moment';
import { ItemInfoProps } from '@/pages/market/Item';

const valueEnum = {
  0: '创建',
  3: '转让',
  7: '转让',
  5: '授权',
};

const columns: ProColumns<API.ModelsFileStorage>[] = [
  {
    title: '交易类型',
    dataIndex: 'type',
    valueEnum,
  },
  {
    title: '出售方',
    render: (_, record) => {
      return record.from;
    },
  },
  {
    title: '购买方',
    render: (_, record) => {
      return record.to;
    },
  },
  {
    title: '价格',
    dataIndex: 'price',
    valueType: 'money',
  },
  {
    title: '交易时间',
    dataIndex: 'blockTime',
    render: (_, record) => {
      return moment.unix(record.block!.time).format('YYYY-MM-DD HH:mm:ss');
    },
  },
];

const TransCard: React.FC<ItemInfoProps> = (props) => {
  const {
    item: { fileStorages },
  } = props;

  return (
    <ProCard
      className={styles.itemCard}
      title="流转记录"
      headerBordered
      bordered
    >
      <ProTable
        bordered
        rowKey="id"
        options={false}
        search={false}
        columns={columns}
        // dataSource={fileStorages}
      />
    </ProCard>
  );
};

export default TransCard;
